<?php
class Translog extends Model {
	function Translog() {
		parent::Model();
	}
	//transaction log
	function insert_log($insert_log) 
	{
		$this->db->insert('transaction_log',$insert_log);
	}
	function show_id_trans_log() 
	{
		$this->db->select('*');
		$this->db->from('transaction_log');
		$this->db->order_by('id','desc');
		
		return $this->db->get();	
	}
	function show_user_log($id) {
		$this->db->select('*');
		$this->db->from('user');
		$this->db->where('user_id',$id);
		
		return $this->db->get();
	}
	function count_all($user_id) {
		$ql ="select a.*,b.name from(transaction_log a,user b) where (a.user_id=b.user_id) and name='$user_id'";
		$sql = $this->db->query($ql);
		return $sql->num_rows();
	}
	function show_all_translog($user_id,$offset) {
		$this->db->select('a.notes,a.datetime,a.ip,b.name');
		$this->db->from('transaction_log a,user b');
		$this->db->where('a.user_id = b.user_id');
		$this->db->where('name',$user_id);
		$this->db->order_by('id','desc');
		$this->db->limit(20,$offset);
		
		return $this->db->get();
	}
}
?>